<?php

namespace app\api\controller;

use app\api\model\Userinfo AS UserinfoModel;

use app\common\controller\Send;
use think\facade\Log;
class Userinfo extends Base
{
    
    
    use Send;
    /**
     * 个人信息资料
     * @return array
     * @throws \think\Exception\DbException
     */
    public function index()
    {
        $reqData = input('');
        $return  = UserinfoModel::updateUserInfo($reqData);      
        Log::write($reqData, 'reqDataxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
        return self::sendResult($return['code'], $return['data'], $return['msg']);
    }
    
    /**
     * 修改密码
     * @return array
     * @throws \think\Exception\DbException
     */
    public function updatepwd()
    {
        $reqData = input('');
        $return  = UserinfoModel::updateUserPwd($reqData);
        
        return self::sendResult($return['code'], $return['data'], $return['msg']);
    }
    /**
     * 添加密码
     * @return array
     * @throws \think\Exception\DbException
     */
    public function addpwd()
    {
        $oauthInfo = $this->oauthInfo;
        $reqData = input('');
        if (empty($reqData['password'])) {
            return self::sendResult(202, [], '请输入要添加的密码');
        }
        $return  = UserinfoModel::addUserPwd($oauthInfo,$reqData);
        return self::sendResult($return['code'], $return['data'], $return['msg']);
    }
    
    /**
     * 中英文切换
     * @return array
     * @throws \think\Exception\DbException
     */
    public function languageChange()
    {
        $reqData = input('');
        $return  = UserinfoModel::updateUserPwd($reqData);
        
        return self::sendResult($return['code'], $return['data'], $return['msg']);
    }
    
    /**
     * 绑定微信
     * @return array
     * @throws \think\Exception\DbException
     */
    public function bindWechat()
    {
        $reqData = input('');
        $return  = UserinfoModel::bindWechat($reqData);
        
        return self::sendResult($return['code'], $return['data'], $return['msg']);
    }
    
    
    /**
     * 解绑微信
     * @return array
     * @throws \think\Exception\DbException
     */
    public function untieWechat()
    {
        $reqData = input('');
        $return  = UserinfoModel::untieWechat($reqData);
    
        return self::sendResult($return['code'], $return['data'], $return['msg']);
    }
    
    /**
     * 绑定设备
     * @return array
     * @throws \think\Exception\DbException
     */
    public function bindDevice()
    {
        $reqData = input('');
        $return  = UserinfoModel::bindDevice($reqData);
        
        return self::sendResult($return['code'], $return['data'], $return['msg']);
    }
    
    
    /**
     * 绑定手机
     * @return array
     * @throws \think\Exception\DbException
     */
    public function bindPhone()
    {
        $reqData = input('');
        $return  = UserinfoModel::bindPhone($reqData);
        
        return self::sendResult($return['code'], $return['data'], $return['msg']);
    }
    
    
    /**
     * 是否绑定微信
     * @return array
     * @throws \think\Exception\DbException
     */
    public function isBindWechat()
    {
        $reqData = input('');
        $return  = UserinfoModel::isBindWechat($reqData);
    
        return self::sendResult($return['code'], $return['data'], $return['msg']);
    }
    
    /**
     * 是否绑定设备
     * @return array
     * @throws \think\Exception\DbException
     */
    public function isBindDevice()
    {
        $reqData = input('');
        $return  = UserinfoModel::isBindDevice($reqData);
    
        return self::sendResult($return['code'], $return['data'], $return['msg']);
    }
    
    
    
    /**
     * 放弃原来的账号绑定新账号
     * @return array
     * @throws \think\Exception\DbException
     */
    public function repeatNewAccount()
    {
        $reqData = input('');
        $return  = UserinfoModel::repeatNewAccount($reqData);
    
        return self::sendResult($return['code'], $return['data'], $return['msg']);
    }
    
    
    /**
     * 游客是否购买课程
     * @return array
     * @throws \think\Exception\DbException
     */
    public function isBuyClass()
    {
        $reqData = input('');
        $return  = UserinfoModel::isBuyClass($reqData);
    
        return self::sendResult($return['code'], $return['data'], $return['msg']);
    }
    
    /**
     * 设备是否绑定账号
     * @return array
     * @throws \think\Exception\DbException
     */
    public function isBindDeviceInfo()
    {
        $reqData = input('');
        $return  = UserinfoModel::isBindDeviceInfo($reqData);
    
        return self::sendResult($return['code'], $return['data'], $return['msg']);
    }


    
}